
package visualizacion;

import java.awt.Dimension;
import java.awt.Point; 
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import javax.swing.JScrollBar;
import javax.swing.JViewport;

public class Ventana extends javax.swing.JFrame {

    /**
     * Creates new form Ventana
     */
    public Ventana() {
        initComponents();
        int a =0;
        int julioculo=-1000000000;
        Dimension dim = Imagen.getSize();
        Iancho=dim.width;
        jTextFieldAncho.setText(String.valueOf(Iancho));
        Ialto=dim.height;
        jTextFieldAlto.setText(String.valueOf(Ialto));
        /*
         * 
         * viewport = scroll.getViewport();
        altoViewportText.setText(String.valueOf(viewport.getSize().height));
        anchoViewportText.setText(String.valueOf(viewport.getSize().width));
        
        scroll.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
                anchoViewportText.setText(String.valueOf(viewport.getSize().width));
            }
        });
        
        scroll.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent e) {
                altoViewportText.setText(String.valueOf(viewport.getSize().height));
            }
        });
        
        posXViewportText.setText(String.valueOf(viewport.getViewPosition().x));
        posYViewportText.setText(String.valueOf(viewport.getViewPosition().y));
         */
        vista = jScrollPane1.getViewport();
        Dimension Vdim= vista.getExtentSize();
        Vancho=Vdim.width;
        jTextFieldVAncho.setText(String.valueOf(Vancho));
        Valto=Vdim.height;
        jTextFieldVAlto.setText(String.valueOf(Valto));
        Point pos=vista.getViewPosition();
        Vx=pos.x;
        jTextFieldVX.setText(String.valueOf(Vx));
        Vy=pos.y;
        jTextFieldVY.setText(String.valueOf(Vy));
        
        Hbar=jScrollPane1.getHorizontalScrollBar();
        Hbar.addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent ae) {
                Point p= vista.getViewPosition();
                Vx=p.x;
                jTextFieldVX.setText(String.valueOf(Vx));
            }
        });
        
        Vbar=jScrollPane1.getVerticalScrollBar();
        Vbar.addAdjustmentListener(new AdjustmentListener() {

            @Override
            public void adjustmentValueChanged(AdjustmentEvent ae) {
                Point p= vista.getViewPosition();
                Vy=p.y;
                jTextFieldVY.setText(String.valueOf(Vy));
            }
        });
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldAncho = new javax.swing.JTextField();
        jTextFieldAlto = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        Imagen = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldCEstado = new javax.swing.JTextField();
        jTextFieldCX = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldCY = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        anchoViewport1 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jTextFieldVAncho = new javax.swing.JTextField();
        jTextFieldVAlto = new javax.swing.JTextField();
        jTextFieldVX = new javax.swing.JTextField();
        jTextFieldVY = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Visualización de Imagenes");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Imagen"));

        jLabel1.setText("Ancho");

        jLabel2.setText("Alto");

        jTextFieldAncho.setEditable(false);

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jLabel1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 26, Short.MAX_VALUE)
                        .add(jTextFieldAncho, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(jLabel2)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(jTextFieldAlto, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(jTextFieldAncho, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel2)
                    .add(jTextFieldAlto, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        jScrollPane1.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                jScrollPane1ComponentResized(evt);
            }
        });

        Imagen.setIcon(new javax.swing.ImageIcon("/Users/julio/NetBeansProjects/practica3DIU/src/Harrier.jpg")); // NOI18N
        Imagen.setText("jLabel4");
        Imagen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mousePressed(java.awt.event.MouseEvent evt) {
                ImagenMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                ImagenMouseReleased(evt);
            }
        });
        Imagen.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                ImagenMouseMoved(evt);
            }
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                ImagenMouseDragged(evt);
            }
        });
        jScrollPane1.setViewportView(Imagen);

        jLabel3.setText("Hecho por Julio López.");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Cursor"));

        jLabel5.setText("Estado");

        jLabel6.setText("Pos X");

        jLabel7.setText("Pos Y");

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel5)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 26, Short.MAX_VALUE)
                        .add(jTextFieldCEstado, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel6)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(jTextFieldCX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(jLabel7)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 34, Short.MAX_VALUE)
                        .add(jTextFieldCY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 80, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(jTextFieldCEstado, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(jTextFieldCX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(jTextFieldCY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Viewport"));

        anchoViewport1.setText("Ancho");

        jLabel10.setText("Alto");

        jLabel11.setText("Pos X");

        jLabel12.setText("Pos Y");

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel10)
                    .add(jLabel11)
                    .add(jLabel12)
                    .add(anchoViewport1))
                .add(20, 20, 20)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jTextFieldVAncho)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jTextFieldVX)
                    .add(jTextFieldVAlto)
                    .add(jTextFieldVY))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(anchoViewport1)
                    .add(jTextFieldVAncho, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel10)
                    .add(jTextFieldVAlto, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel11)
                    .add(jTextFieldVX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextFieldVY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel12))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 671, Short.MAX_VALUE)
                        .add(18, 18, 18)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .add(20, 20, 20))
                    .add(layout.createSequentialGroup()
                        .add(jLabel3)
                        .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(18, 18, 18)
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(13, 13, 13)
                        .add(jPanel4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel3)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ImagenMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ImagenMousePressed
        // TODO add your handling code here:
        Imagen.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jTextFieldCEstado.setText("PRESSED");
        Point p= Imagen.getMousePosition();
        Cx0=p.x;
        Cy0=p.y;
        p0=vista.getViewPosition();
    }//GEN-LAST:event_ImagenMousePressed

    private void ImagenMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ImagenMouseReleased
        // TODO add your handling code here:
        Imagen.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jTextFieldCEstado.setText("");
    }//GEN-LAST:event_ImagenMouseReleased

    private void ImagenMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ImagenMouseDragged
        // TODO add your handling code here:
        jTextFieldCEstado.setText("DRAGGED");
        Point pos = Imagen.getMousePosition();
        Cx=pos.x;
        jTextFieldCX.setText(String.valueOf(Cx));
        Cy=pos.y;
        jTextFieldCY.setText(String.valueOf(Cy));
        
        Point p=new Point();
        p.x=p0.x- (int) ((Cx-Cx0)/1.5);
        p.y=p0.y- (int) ((Cy-Cy0)/1.5);
        if(p.x<0)p.x=0;
        if(p.x>Iancho-Vancho)p.x=Iancho-Vancho;
        if(p.y<0)p.y=0;
        if(p.x>Ialto-Valto)p.x=Ialto-Valto;
        vista.setViewPosition(p);
        
        
    }//GEN-LAST:event_ImagenMouseDragged

    private void ImagenMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ImagenMouseMoved
        // TODO add your handling code here:
        Point pos = Imagen.getMousePosition();
        Cx=pos.x;
        jTextFieldCX.setText(String.valueOf(Cx));
        Cy=pos.y;
        jTextFieldCY.setText(String.valueOf(Cy));
    }//GEN-LAST:event_ImagenMouseMoved

    private void jScrollPane1ComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jScrollPane1ComponentResized
        // TODO add your handling code here:
        Dimension Vdim= vista.getExtentSize();
        Vancho=Vdim.width;
        jTextFieldVAncho.setText(String.valueOf(Vancho));
        Valto=Vdim.height;
        jTextFieldVAlto.setText(String.valueOf(Valto));
    }//GEN-LAST:event_jScrollPane1ComponentResized

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Ventana.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ventana().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Imagen;
    private javax.swing.JTextField altoViewportText;
    private javax.swing.JLabel anchoViewport;
    private javax.swing.JLabel anchoViewport1;
    private javax.swing.JTextField anchoViewportText;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextFieldAlto;
    private javax.swing.JTextField jTextFieldAncho;
    private javax.swing.JTextField jTextFieldCEstado;
    private javax.swing.JTextField jTextFieldCX;
    private javax.swing.JTextField jTextFieldCY;
    private javax.swing.JTextField jTextFieldVAlto;
    private javax.swing.JTextField jTextFieldVAncho;
    private javax.swing.JTextField jTextFieldVX;
    private javax.swing.JTextField jTextFieldVY;
    private javax.swing.JTextField posXViewportText;
    private javax.swing.JTextField posYViewportText;
    // End of variables declaration//GEN-END:variables
    private int Iancho,Ialto;
    private int Cx,Cy,Cx0,Cy0;
    private JViewport vista;
    private int Vancho,Valto,Vx,Vy;
    private JScrollBar Hbar,Vbar;
    private Point p0;
}
